 var state=1;
 document.addEventListener('UniAppJSBridgeReady', function() {
 $.post("/api/testDetail.json",'id='+id,function(data){
       if(data.data.state==1){
            $("#btn_div").show();
       }else if(data.data.state!==2){
            $("div[contentEditable]").removeAttr('contentEditable');
            $("#btn_div").hide();
       }
       $.post("/api/testFile.json",'id='+id,function(data){
            $("#img_div").empty();
           $.each(data.data,function(i,o){
                if(o.name.indexOf('.mp4')==-1)
                    $("#img_div").append('<img src="/core/file/download/'+o.id+'" style="margin-top: 20px;width: 600pt;">');
           });
       })
       if(data.data.state==2){//生成报告
            $('title').text("生成检测报告");
            $('#upload').hide();
            $('#doSubmit2').text("提交报告审核");
            state=2;
            var date = new Date();
               var seperator1 = "-";
               var year = date.getFullYear();
               var month = date.getMonth() + 1;
               var strDate = date.getDate();
               if (month >= 1 && month <= 9) {
                   month = "0" + month;
               }
               if (strDate >= 0 && strDate <= 9) {
                   strDate = "0" + strDate;
               }
               var currentdate = year + seperator1 + month + seperator1 + strDate;
               if($('.WordSection1').text().indexOf('江西省防雷装置检测检验报告')==-1)
                    $('.WordSection1').prepend( "<p class=MsoNormal style='margin-bottom:7.8pt'><b><span lang=EN-US\n" +
                                    "style='font-family:黑体'>&nbsp;</span></b></p>\n" +
                                    "<p class=MsoNormal style='margin-bottom:7.8pt'><b><span lang=EN-US\n" +
                                    "style='font-family:黑体'>&nbsp;</span></b></p>\n" +
                                    "<p class=MsoNormal align=center style='text-align:center'><span\n" +
                                    "style='text-fit:417.6pt'><b><span style='font-size:26.0pt;font-family:方正小标宋简体;\n" +
                                    "letter-spacing:3.3pt'>江西省防雷装置检测检验报告</span></b></span></p>\n" +
                                    "<p class=MsoNormal align=center style='text-align:center'><span lang=EN-US\n" +
                                    "style='font-size:16.0pt;font-family:仿宋_GB2312'>&nbsp;</span></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal align=center style='text-align:center'><span lang=EN-US\n" +
                                    "style='font-size:16.0pt;font-family:仿宋_GB2312'>&nbsp;</span></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal align=center style='text-align:center'><span lang=EN-US\n" +
                                    "style='font-size:16.0pt;font-family:仿宋_GB2312'>&nbsp;</span></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal align=center style='text-align:center'><span lang=EN-US\n" +
                                    "style='font-size:16.0pt;font-family:仿宋_GB2312'>&nbsp;</span></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal style='margin-left:56.0pt'><span style='text-fit:96.3pt'><b><span\n" +
                                    "style='font-size:16.0pt;letter-spacing:5.35pt'>受检单位</span></b></span><b><span\n" +
                                    "style='font-size:16.0pt'>：<u><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;"+data.data.testName+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n" +
                                    "</span></u></span></b></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal style='text-indent:32.15pt'><b><span lang=EN-US\n" +
                                    "style='font-size:16.0pt'>&nbsp;</span></b></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal style='margin-left:56.0pt'><span style='text-fit:96.3pt'><b><span\n" +
                                    "style='font-size:16.0pt;letter-spacing:5.35pt'>检测对象</span></b></span><b><span\n" +
                                    "style='font-size:16.0pt'>：<u><span lang=EN-US>&nbsp;&nbsp;&nbsp;"+data.data.tester+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n" +
                                    "</span></u></span></b></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal style='text-indent:32.15pt'><b><span lang=EN-US\n" +
                                    "style='font-size:16.0pt'>&nbsp;</span></b></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal style='margin-left:56.0pt'><span style='text-fit:96.3pt'><b><span\n" +
                                    "style='font-size:16.0pt;letter-spacing:5.35pt'>检测日期</span></b></span><b><span\n" +
                                    "style='font-size:16.0pt'>：<u><span lang=EN-US>&nbsp;&nbsp;&nbsp;"+data.data.testDate+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n" +
                                    "</span></u></span></b></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal style='text-indent:56.2pt'><b><span lang=EN-US\n" +
                                    "style='font-size:16.0pt'>&nbsp;</span></b></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal style='margin-left:56.0pt'><b><span style='font-size:16.0pt'>报告发送日期：<u><span\n" +
                                    "lang=EN-US>&nbsp;&nbsp;&nbsp;"+currentdate+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n" +
                                    "</span></u></span></b></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal align=center style='text-align:center'><span lang=EN-US\n" +
                                    "style='font-family:仿宋_GB2312'>&nbsp;</span></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal align=center style='text-align:center'><span lang=EN-US\n" +
                                    "style='font-family:仿宋_GB2312'>&nbsp;</span></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal align=center style='text-align:center'><b><span lang=EN-US\n" +
                                    "style='font-size:18.0pt'>&nbsp;</span></b></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal align=center style='text-align:center'><b><u><span\n" +
                                    "lang=EN-US style='font-size:18.0pt;font-family:\"Times New Roman\",serif'>赣州\n" +
                                    "</span></u></b><b><span style='font-size:18.0pt'>市防雷装置质量检测检验所</span></b></p>\n" +
                                    "<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0style='border-collapse:collapse'><tr style='height:19.85pt'><td >"+
                                    "<span style='font-size:15.0pt'>地址：</span><span\n" +
                                    "lang=EN-US style='font-size:15.0pt;font-family:\"Times New Roman\",serif'></td><td> <div contentEditable='true' class='write' style='width:200px;height:30px'></div>\n" +
                                    "</span></td><td><span style='font-size:15.0pt'>电话：</span></td><td> <div contentEditable='true' class='write' style='width:200px;height:30px'></div></td><tr><td>\n" +
                                    "\n" +
                                    "<span style='font-size:15.0pt'>传真：</span></td><td><span\n" +
                                    "lang=EN-US style='font-size:15.0pt;font-family:\"Times New Roman\",serif'> <div contentEditable='true' class='write' style='width:200px;height:30px'></div>\n" +
                                    "</span></td><td><span style='font-size:15.0pt'>邮编：</span></td><td><div contentEditable='true' class='write' style='width:200px;height:30px'></div></td></tr></table>\n" +
                                    "\n" +
                                    "<p class=MsoNormal><span lang=EN-US>&nbsp;</span></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal align=center style='margin-top:0cm;margin-right:21.0pt;\n" +
                                    "margin-bottom:0cm;margin-left:14.0pt;margin-bottom:.0001pt;text-align:center'><span\n" +
                                    "style='font-size:22.0pt;font-family:黑体'>说</span><span lang=EN-US\n" +
                                    "style='font-size:22.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span\n" +
                                    "style='font-size:22.0pt;font-family:黑体'>明</span></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal align=center style='margin-right:31.5pt;text-align:center'><span\n" +
                                    "lang=EN-US style='font-size:22.0pt'>&nbsp;</span></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal style='text-indent:28.0pt;line-height:36.0pt'><span\n" +
                                    "lang=EN-US>1</span>、本报告由检测单位用微机打印或蓝、黑钢笔认真填写，要求字迹清楚，结论准确，使用法定计量单位，报告内容不许涂改。</p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal style='text-indent:28.0pt;line-height:36.0pt'><span\n" +
                                    "lang=EN-US>2</span>、报告相应栏目中必须有检测人员、审核人员、批准人亲笔签名，检测单位加盖公章。无签名或签名不全及无检测单位公章的检测报告无效。</p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal style='text-indent:28.0pt;line-height:36.0pt'><span\n" +
                                    "lang=EN-US>3</span>、未经检测单位书面批准，不得复制本报告。复制本报告未重新加盖检测单位公章无效。</p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal style='text-indent:28.0pt;line-height:36.0pt'><span\n" +
                                    "lang=EN-US>4</span>、封面左上角加盖检测单位计量认证合格标志印章的检测报告对社会有效。</p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal style='text-indent:28.0pt;line-height:36.0pt'><span\n" +
                                    "lang=EN-US>5</span>、本报告一式贰份，一份送受检测单位，一份留检测单位存档。</p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal style='text-indent:28.0pt;line-height:36.0pt'><span\n" +
                                    "lang=EN-US>6</span>、自检测报告发出之日起十五日内受理对检测数据持有异议提出的申诉。</p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal style='text-indent:28.0pt;line-height:36.0pt'><span\n" +
                                    "lang=EN-US>7</span>、<span style='font-size:16.0pt'>检测有效期至××××年×月××日，下次检测日期为××××年×月。</span></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal align=center style='text-align:center'><b><span lang=EN-US\n" +
                                    "style='font-size:22.0pt;font-family:黑体'>&nbsp;</span></b></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal align=center style='text-align:center'><b><span lang=EN-US\n" +
                                    "style='font-size:22.0pt;font-family:黑体'>&nbsp;</span></b></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal align=center style='text-align:center'><b><span lang=EN-US\n" +
                                    "style='font-size:22.0pt;font-family:黑体'>&nbsp;</span></b></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal align=center style='text-align:center'><b><span lang=EN-US\n" +
                                    "style='font-size:22.0pt;font-family:黑体'>&nbsp;</span></b></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal align=center style='text-align:center'><b><span lang=EN-US\n" +
                                    "style='font-size:22.0pt;font-family:黑体'>&nbsp;</span></b></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal align=center style='text-align:center'><b><span lang=EN-US\n" +
                                    "style='font-size:22.0pt;font-family:黑体'>&nbsp;</span></b></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal align=center style='text-align:center'><b><span lang=EN-US\n" +
                                    "style='font-size:22.0pt;font-family:黑体'>&nbsp;</span></b></p>\n" +
                                    "\n" +
                                    "<p class=MsoNormal align=center style='text-align:center'><b><span lang=EN-US\n" +
                                    "style='font-size:22.0pt;font-family:黑体'>&nbsp;</span></b></p>")
       }
 })

 });
 function toUpload(evt) {
   uni.navigateTo({
       url: '/pages/jiance/upload'
   });
}
function doSubmit() {
     $.post("/api/saveTest.do",'state='+state+'&id='+id+'&htmldata='+encodeURIComponent(document.getElementsByTagName('html')[0].innerHTML),function(data){
         alert("保存成功！");
     })
 }
  function doSubmit2() {
     $.post("/api/saveTest.do",'state='+(state+1)+'&id='+id+'&htmldata='+encodeURIComponent(document.getElementsByTagName('html')[0].innerHTML),function(data){
         alert("提交审核成功！");
         uni.navigateBack({
             delta: 2
         });
     })
 }